package partone2.exer03;

/**
 * @author shkstart
 * @date 2022/4/30 - 18:49
 */
public class Account {
    private int id;//账号
    private double balance;//余额
    private double annualInterestRate;//年利率

    public Account(int id,double balance,double annualInterestRate){
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId(){
        return id;
    }

    public double getBalance(){
        return balance;
    }

    public double getAnnualInterestRate(){
        return annualInterestRate;
    }


    public void setId(int id){
        this.id = id;
    }

    public void setBalance(double balance){
        this.balance = balance;
    }

    public void setAnnualInterestRate(double annualInterestRate){
        this.annualInterestRate = annualInterestRate;
    }


    public void withdraw(double amount){
    //在提款方法withdraw中，需要判断用户余额是否能够满足提款数额的要求，如果不能，应给出提示。
        if(balance < amount){
            System.out.println("余额不足，取款失败");
            return;
        }

        balance -= amount;
        System.out.println("成功取出" + amount + "钱");

    }


    public void deposit(double amount){
        if(amount > 0){
            balance += amount;
            System.out.println("成功存入" + amount);
        }
    }
}
